<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">
	<f:view>
		<p:tabView id="tab">
		<p:tab title="Dados Pessoais">
			<h:panelGroup id="group_verifica_cpf" rendered="#{!medicoManager.isCpfValido}">
				<h:panelGrid columns="2">
					
					<h:outputText value="CPF" />
					<h:outputText value="" />
					<p:inputMask id="cpf" mask="999.999.999-99" value="#{medicoManager.medico.cpf}" required="true" label="CPF" converter="cpfConverter" />
					<p:commandButton value="Verificar" id="verificar_cpf" process="group_verifica_cpf" update=":form:panel_medico" action="#{medicoManager.validateCpf}" />
					
					
				</h:panelGrid>
			</h:panelGroup>
			
			<h:panelGroup rendered="#{medicoManager.isCpfValido}">
				<h:panelGrid columns="2" cellpadding="0" cellspacing="0">
				<h:outputText value="CPF" />
				<h:outputText value="Nome" />
				<p:inputMask mask="999.999.999-99" id="cpf_read" value="#{medicoManager.medico.cpf}" required="true" label="CPF" converter="cpfConverter" maxlength="14" readonly="true"/>
				<p:inputText value="#{medicoManager.medico.nome}" id="nome" label="Nome" required="true" maxlength="255" style="width:400px;">
					<f:validateLength maximum="255" minimum="2"/>
				</p:inputText>
			</h:panelGrid>
			
			<h:panelGrid columns="4" cellpadding="0" cellspacing="0">
				<h:outputText value="RG" />
				<h:outputText value="Nascimento" />
				<h:outputText value="Sexo" />
				<h:outputText value="CRM" />
				
				<p:inputText value="#{medicoManager.medico.rg}" maxlength="255" id="rg" label="RG">
					<f:validateLength maximum="255" minimum="0"/>
				</p:inputText>
				<p:calendar value="#{medicoManager.medico.dataNascimento}" datePattern="dd/MM/yyyy" yearRange="1900" locale="pt"
							label="Data de Nascimento" id="nascimento" navigator="true" readOnlyInputText="true" />
				<p:selectOneRadio value="#{medicoManager.medico.sexo}" required="true" label="Sexo" id="sexo">
					<f:selectItem itemValue="M" itemLabel="Masculino" />
					<f:selectItem itemValue="F" itemLabel="Feminino" />
				</p:selectOneRadio>
				
				<p:inputText value="#{medicoManager.medico.crm}" />
				
			</h:panelGrid>
				
			<p:panel header ="Endereço">
				<ui:include src="/geral/paginas/geral/formEndereco.xhtml" />
			</p:panel>
			<p:panel header="Telefones" rendered="#{medicoManager.isCpfValido}">
				<ui:include src="/geral/paginas/geral/formTelefone.xhtml" />
			</p:panel>
		</h:panelGroup>
		</p:tab>
		<p:tab title="Dados Profissionais" rendered="#{medicoManager.isCpfValido}">
			<h:panelGrid columns="2">
				
				<h:outputText value="Matrícula" />
				<h:inputText value="#{medicoManager.medico.matricula}" />
				
				<h:outputText value="Cargo" />
				<h:selectOneMenu value="#{medicoManager.medico.cargo.id}" label="Cargo" id="cargo">
					<f:selectItem itemLabel="- Selecione - " />
					<f:selectItems value="#{funcionarioManager.listCargo}" var="ps" itemLabel="#{ps.descricao}" itemValue="#{ps.id}"/>
				</h:selectOneMenu>
				
				<h:outputText value="Função" />
				<h:selectOneMenu value="#{medicoManager.medico.funcao.id}" label="Função" id="funcao">
					<f:selectItem itemLabel="- Selecione - " />
					<f:selectItems value="#{funcionarioManager.listFuncao}" var="ps" itemLabel="#{ps.descricao}" itemValue="#{ps.id}"/>
				</h:selectOneMenu>
				
				<h:outputText value="Horas Trabalhadas por Dia" />
				<h:selectOneMenu value="#{medicoManager.medico.horarioFuncionario.id}" label="Horário do Funcionário" id="horario">
					<f:selectItem itemLabel="- Selecione - " />
					<f:selectItems value="#{funcionarioManager.listHorario}" var="ps" itemLabel="#{ps.totalHorasTrabalhadasDia}" itemValue="#{ps.id}"/>
				</h:selectOneMenu>
				
				<h:outputText value="Data de Admissão" />
				<p:calendar value="#{medicoManager.medico.dataEntrada}" datePattern="dd/MM/yyyy" yearRange="1900" locale="pt"
							label="Data de Admissão" id="admissao" navigator="true" readOnlyInputText="true" />
				
				<h:outputText value="Data de Demissão" />
				<p:calendar value="#{medicoManager.medico.dataSaida}" datePattern="dd/MM/yyyy" yearRange="1900" locale="pt"
							label="Data de Demissão" id="demissao" navigator="true" readOnlyInputText="true" />
				
				<h:outputText value="Em férias?" />
				<h:selectBooleanCheckbox value="#{medicoManager.medico.isFerias}" />
				
				<h:outputText value="Data de Início das Férias" />
				<p:calendar value="#{medicoManager.medico.dataInicioFerias}" datePattern="dd/MM/yyyy" yearRange="1900" locale="pt"
							label="Data de Início das Férias" id="inicioFerias" navigator="true" readOnlyInputText="true" />
							
				<h:outputText value="Data de Retorno das Férias" />
				<p:calendar value="#{medicoManager.medico.dataRetornoFerias}" datePattern="dd/MM/yyyy" yearRange="1900" locale="pt"
							label="Data de Retorno das Férias" id="retornoFerias" navigator="true" readOnlyInputText="true" />
							
				<h:outputText value="Dias da Semana que realiza Atendimentos" />
				<h:selectManyCheckbox value="#{medicoManager.listDiasSemana}" converter="diaConverter">
					<f:selectItems value="#{utilManager.listDiasSemana}" />
				</h:selectManyCheckbox>
				
			</h:panelGrid>

			<p:panel header="Especialidades" id="especialidades" rendered="#{medicoManager.isCpfValido and segurancaManager.isClinica}">
				<ui:include src="/medico/paginas/medico/especialidade.xhtml" />
			</p:panel>
			<p:panel header="Planos de Saúde" id="plano_saudes" rendered="#{medicoManager.isCpfValido and segurancaManager.isClinica}">
				<ui:include src="/medico/paginas/medico/planoSaude.xhtml" />							
			</p:panel>
		</p:tab>
		<p:tab title="Dados de Acesso ao Sistema" rendered="#{medicoManager.isCpfValido}">
			<h:panelGrid columns="2">
				<h:outputText value="Perfil" />
				<h:selectOneMenu value="#{medicoManager.medico.usuario.perfilUsuario.id}" label="Perfil" id="perfil">
					<f:selectItem itemLabel="- Selecione - " />
					<f:selectItems value="#{funcionarioManager.listPerfil}" var="ps" itemLabel="#{ps.nomePerfil}" itemValue="#{ps.id}"/>
				</h:selectOneMenu>
				
				<h:outputText value="Usuário do Sistema" />
				<h:inputText value="#{medicoManager.medico.usuario.login}" />
				
				<h:outputText value="Senha" />
				<p:password value="#{medicoManager.medico.usuario.senha}" />
			</h:panelGrid>
			
		</p:tab>
	</p:tabView>
		
		
	<p:commandButton action="#{medicoManager.save}" value="Salvar" rendered="#{medicoManager.isCpfValido and medicoManager.medico.id == null}"  update="form"/>
	<p:commandButton action="#{medicoManager.update}" value="Salvar" rendered="#{medicoManager.isCpfValido and medicoManager.medico.id != null}"  update="form" />
		
	</f:view>
</html>